package objects2d;
import box2D.collision.shapes.B2PolygonShape;
import box2D.dynamics.B2BodyDef;
import box2D.dynamics.B2FixtureDef;
import box2D.dynamics.B2Fixture;
import box2D.dynamics.B2World;
import box2D.dynamics.B2Body;

import openfl.display.Sprite;

/**
 * ...
 * @author Marcos Martinez
 */
class Ground2D
{
	private var m_cCanvas:Sprite;
	private var m_cWorld:B2World;
	private var m_cGroundBody:B2Body;
	private var m_cGroundBodyDef:B2BodyDef;
	private var m_cGroundShape:B2PolygonShape;
	private var m_cGroundFixtureDef:B2FixtureDef;
	private var m_cGroundFixture:B2Fixture;
	
	
	public function new(cWorld:B2World) 
	{
		m_cCanvas = new Sprite();
		m_cWorld = cWorld;
		
	}
	
	public function create(nPosX:Float, nPosY:Float, nWidth:Float, nHeight:Float):Void
	{
		m_cGroundBodyDef = new B2BodyDef();
		m_cGroundBodyDef.position.set(nPosX,  nPosY);
		m_cGroundBody = m_cWorld.createBody(m_cGroundBodyDef);
		m_cGroundShape = new B2PolygonShape();
		m_cGroundShape.setAsBox(nWidth, nHeight);
		m_cGroundFixtureDef = new B2FixtureDef();
		m_cGroundFixtureDef.shape = m_cGroundShape;
		m_cGroundFixture = m_cGroundBody.createFixture(m_cGroundFixtureDef);
	}
}